﻿@model CustomerListModel

<div class="form-group">
    <smart-label asp-for="SearchEmail" />
    <input asp-for="SearchEmail" class="form-control-sm" />
</div>
<div sm-if="Model.UsernamesEnabled" class="form-group">
    <smart-label asp-for="SearchUsername" />
    <input asp-for="SearchUsername" class="form-control-sm" />
</div>
<div class="form-group">
    <smart-label asp-for="SearchTerm" />
    <editor asp-for="SearchTerm" asp-template="SearchExpression" placeholder="@T("Admin.Customers.Customers.List.SearchTerm.Hint")" class="form-control-sm" />
</div>
<div class="form-group">
    <smart-label asp-for="SearchCustomerNumber" />
    <input asp-for="SearchCustomerNumber" class="form-control-sm" />
</div>
<div class="form-group">
    <smart-label sm-text="@T("Common.CreatedOn")" sm-ignore-hint="true" asp-for="StartDate" />
    <div class="form-row">
        <div class="col-6">
            <editor asp-for="StartDate" asp-additional-viewdata='new { size = "sm" }' placeholder="@T("Common.From")" />
        </div>
        <div class="col-6">
            <editor asp-for="EndDate" asp-additional-viewdata='new { size = "sm" }' placeholder="@T("Common.To")" />
        </div>
    </div>
</div>
@if (Model.DateOfBirthEnabled)
{
    // INFO: we assume customers must be at least 14 years old and are not older than 70.
    var yearOfBirthValues = Enumerable.Range(1950, DateTime.UtcNow.Year - 1963)
        .Select(i => new SelectListItem { Text = i.ToString(CultureInfo.InvariantCulture), Value = i.ToString(CultureInfo.InvariantCulture) })
        .ToList();

    var monthOfBirthValues = Enumerable.Range(1, 12)
        .Select(i => new SelectListItem { Text = i.ToString(CultureInfo.InvariantCulture), Value = i.ToString(CultureInfo.InvariantCulture) })
        .ToList();

    var dayOfBirthValues = Enumerable.Range(1, 31)
        .Select(i => new SelectListItem { Text = i.ToString(CultureInfo.InvariantCulture), Value = i.ToString(CultureInfo.InvariantCulture) })
        .ToList();

    <div class="form-group">
        <smart-label asp-for="SearchMonthOfBirth" />
        <div class="form-row flex-nowrap">
            <div class="col">
                <select asp-for="SearchYearOfBirth" asp-items="@yearOfBirthValues" asp-placeholder="@T("Common.Year")" class="form-control-sm noskin"></select>
            </div>
            <div class="col">
                <select asp-for="SearchMonthOfBirth" asp-items="@monthOfBirthValues" asp-placeholder="@T("Admin.Customers.Customers.List.SearchDateOfBirth.Month")" class="form-control-sm noskin"></select>
            </div>
            <div class="col">
                <select asp-for="SearchDayOfBirth" asp-items="@dayOfBirthValues" asp-placeholder="@T("Admin.Customers.Customers.List.SearchDateOfBirth.Day")" class="form-control-sm noskin"></select>
            </div>
        </div>
    </div>
}
<div sm-if="Model.PhoneEnabled" class="form-group">
    <smart-label asp-for="SearchPhone" />
    <input asp-for="SearchPhone" class="form-control-sm" />
</div>
<div sm-if="Model.ZipPostalCodeEnabled" class="form-group">
    <smart-label asp-for="SearchZipPostalCode" />
    <input asp-for="SearchZipPostalCode" class="form-control-sm" />
</div>
<div class="form-group">
    <smart-label asp-for="SearchCustomerRoleIds" />
    <editor asp-for="SearchCustomerRoleIds" class="form-control-sm" />
</div>
<div class="form-group">
    <smart-label asp-for="SearchActiveOnly" />
    <editor asp-for="SearchActiveOnly" class="form-control-sm" />
</div>